const express = require('express');
const {addUserService, getUserListService, getUserByIdService} = require("../service/userService");
const {getUserConsultById} = require("../dao/userDao");
const router = express.Router();

// 添加用户
router.post('/', async function (req, res, next) {
    res.send(await addUserService(req.body))
})
// 分页获取用户
router.get('/', async function (req, res, next) {
    res.send(await getUserListService(req.query.page, req.query.limit))
})
// 根据id获取单个用户信息
router.get('/:id', async function (req, res, next) {
    res.send(await getUserByIdService(req.params.id))
})
// 根据id 查找某个用户提出的所有问题和回复的所有问题
router.get('/:id/consult', async function (req, res, next) {
    res.send(await getUserConsultById(req.params.id))
})

module.exports = router;
